1. Field of the Invention
The present invention relates, in general, to computer graphics such as graphics systems, hardware, and software used for image generation including interactive and/or frequently changing/update image generation for video games and other applications, and, more particularly, to computer graphics systems and methods for use in interactive video games and other applications that provide improved fog effects.
2. Relevant Background
Recently, the video game industry has been enjoying tremendous growth with increasing demand for video games with visually appealing, captivating, and artistic animation. Video games are widely played using video game systems and a monitor such as television and using a computer and its hardware and monitor such as to play multi-player online or Web-based games. More recently, video games and similar applications have been provided in many more setting such as in vehicles and on handheld/portable electronic devices such as cellphones, handheld gaming devices, personal digital assistants. It is expected that the demand for video games with desirable animation will only continue to grow in the coming years.
Computer graphics systems are used in many video games and other animation applications to render animation in a responsive or interactive manner. Graphics system designers generally attempt to provide realism or some artistic quality in their graphics systems by closely modeling a three dimensional (3D) virtual world based on the real world. For example, graphics systems allow game designers to place 3D objects such as mountains, houses, characters, animals, and so on in a scene that is to be animated during game play. Interfaces also allow the game designers and animators to select colors for each of these 3D objects and even for each pixel within the animated object. Further, the animator may select where to place a light source, such as the Sun, within the animated scene and select a location of a camera (or eye-coordinate) to set a point of view for the scene. As a result, the animator is able to create a scene with carefully colored/painted objects that are highlighted in a desired manner with lighting and shadows, and the scene is viewed from a location chosen by the game designer (or that changes as the player moves a character and with them a camera or eye-coordinate).
In the real world, object become more difficult to see with distance due to atmospheric effects, and, if these effects are not taken into account, computer-generated images have a distinctive, clear quality that is unrealistic. To address this difference between the real world and animated worlds, graphics systems are used to change clarity of the images due to atmospheric effects such as fog, smog, mist, smoke, pollution and the like, with all of these effects generally lumped together and called “fog” or a “fog effect” in computer graphics. Adding fog to a 3D scene can enhance realism, provide ambiance, and obscure artifacts sometimes caused when distant geometry comes into view.
Various mechanisms have been used in graphics systems to simulate fog or provide a fog effect. Essentially, fog is implemented by blending the color of objects in a scene with a chosen fog color based on the depth of an object in a scene or its distance from the viewpoint or camera. As objects grow more distant, their original color blends more and more with the artist/designer-selected fog color. This blending of the two colors creates the illusion (typically, on a pixel by pixel basis) that the object is being increasingly obscured by fog or other atmospheric effects present in the scene or simply based on distance as is the case in the real world. For example, gray may be chosen for the fog color and a pixel within an object may have a yellow color. As the object's pixel becomes more and more distant from the camera or viewpoint (e.g., location of a video game character) the amount or percentage of gray is increased until the pixel is rendered using only gray, which causes the pixel to fade out of view in the animation.
Hence, the range-based fog effect method determines how far the viewer is from the object (e.g., determines a z value or distance from an eye or camera coordinate to an object) and, depending on this z value, blends the object to a certain degree with the color of the fog (e.g., averages the pixel's color with the predefined fog color). Thus, objects appear to fade away in fog the farther away they are from the viewer. The game designer or programmer also may specify, such as via a game interface or application programming interface (API), how much visibility drops off with distance, such as may be used to indicate a thickness or density of fog, smoke, or other atmospheric effect. The visibility drop off or fade value may be referred to as the “fog scale” herein and may be defined in a linear, an exponential, an exponential-squared, or other manner. While the fog scale can be used to define the effect as the viewer's distance changes, the fog itself typically has a uniform density or is homogeneous throughout the animated scene. However, four values generally are used to create existing fog effects, i.e., pixel color, fog color, a z value (or distance from camera/viewpoint), and a fog scale or blending factor.
The blending effect may be carried out in different ways such as using pixel fog (or table fog) or vertex fog. The blending effect under the pixel fog model is calculated on a per-pixel basis in the graphics system's device driver. The vertex fog model makes calculations in the pipeline when transformation and lighting calculations are performed. The vertex fog model calculates the blending for each vertex in a polygon and then interpolates the effect across the face of the polygon. One extension is layered fog. Layered fog utilizes a heterogeneous approach to fog density. Fog is created in layers, with each layer having its own density. This is a more costly processing approach, though, since calculations must be made for each layer, and these calculations must be blended together for a final result. This effect can most easily be pictured if the layers are arranged by decreasing density along the y axis, such that the fog is most dense near the ground. For example, a swamp where heavy fog is present on the ground and the fog dissipates the further up it moves. One important distinction is that fog can either be applied on a per pixel basis or on a per vertex basis and then interpolated to decide the values for each pixel. In each of these methodologies, the fog effect or amount of blending/fading is typically tied to the z value or distance from the viewpoint/camera, and pixels at a particular distance from the camera (or with a like z value) are generally treated identically throughout the animated image with application of an identical blending factor (or fog scale). For example, two trees on opposite sides of a mountain that are the same distance from a viewpoint/camera in a scene would have their pixels blended with a fog color in an identical manner.